package com.example.avmanagerweb.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.avmanagerweb.entity.vo.SosqryVo;
import com.example.avmanagerweb.result.RLIST;
import com.example.avmanagerweb.service.SosqryService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xg
 * @since 2023-06-28
 */
@RestController
@RequestMapping("/sosqry")
public class SosqryController {

    @Autowired
    private SosqryService sosqryService;
    @GetMapping(value = "/querySosqry")
    public RLIST querySosqry(@RequestBody SosqryVo sosqryVo){
        /**
         * 是否做部门id做范围区分
         */
        System.out.println("123");
        //设备名称
        String dvNum = sosqryVo.getDvNum();
        //用户名称
        String uName = sosqryVo.getUName();
        //开始时间
        String begin = sosqryVo.getBegin();
        //结束时间
        String end = sosqryVo.getEnd();
        QueryWrapper queryWrapper = new QueryWrapper();
        if(!StringUtils.isEmpty(dvNum)){
            queryWrapper.eq("dvNum",dvNum);
        }
        if(!StringUtils.isEmpty(uName)){
            queryWrapper.like("uname",uName);
        }
        queryWrapper.ge("sosDate",begin);
        queryWrapper.le("sosDate",end);
        queryWrapper.orderByDesc("sosDate");
        List list = sosqryService.list(queryWrapper);
        return RLIST.ok().data("data",list);
    }

}

